{% extends 'base.html' %}

{% block css %}



{% endblock %}


{% block book_active %}
    active
{% endblock %}

{% block content %}

    <h3 class="sub-header">书籍列表</h3>
    <div class="table-responsive">

        <a class="btn btn-primary btn-sm" href="/book_add/"> 添加 </a>

        <table class="table table-striped">
            <thead>
            <tr>
                <th>序号</th>
                <th>ID</th>
                <th>书名</th>
                <th>作者</th>
                <th>出版社</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            {% for book in all_books %}

                <tr>
                    <td>{{ forloop.counter }}</td>
                    <td>{{ book.pk }}</td>
                    <td>{{ book.title }}</td>
                    <td>
                        {% for author in book.author_set.all %}
                            {{ author.name }}
                        {% endfor %}


                    </td>
                    <td>{{ book.pub.name }}</td>
                    <td>
                        <a class="btn btn-danger btn-sm" href="{% url 'delete' 'book' book.pk %}">删除</a>
                        <a class="btn btn-warning btn-sm" href="/book_edit/?pk={{ book.pk }}">编辑</a>
                    </td>

                </tr>
            {% endfor %}


            </tbody>
        </table>

        {% load my_tags %}
        {% page 3 %}
    </div>

{% endblock %}